package com.futureweaver.advice;

import com.futureweaver.resposne.vo.CustomResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class ExceptionProcesser {
    @ExceptionHandler
    @ResponseBody
    public CustomResponseEntity process(HttpServletRequest request, Exception ex) {
        CustomResponseEntity result = new CustomResponseEntity();
        result.setSuccess(false);
        result.setMsg(ex.getMessage());
        return result;
    }
}
